import i18n, { t } from '@src/locales'
/* entity */
import Field from '@model/entity/Field'
/* enum */
import { TaskFieldDisplayNameMappingEnum, TaskFieldNameMappingEnum } from '@model/enum/FieldMappingEnum'

export const TaskReceiptExportFields: Field[] = [
  {
    isSystem: 1,
    fieldName: 'spare_name',
    field: 'spare_name',
    displayName: t('common.fields.sparePart.displayName'),
    label: t('common.fields.sparePart.displayName'),
    formType: 'text',
    isNull: 1,
    isSearch: 0,
  },
  {
    isSystem: 1,
    fieldName: 'service_name',
    field: 'service_name',
    displayName: t('common.fields.serviceName.displayName'),
    label: t('common.fields.serviceName.displayName'),
    formType: 'text',
    isNull: 1,
    isSearch: 0,
  },
  {
    isSystem: 1,
    fieldName: 'balance_total',
    field: 'balance_total',
    displayName: t('common.fields.balanceTotal.displayName'),
    label: t('common.fields.balanceTotal.displayName'),
    formType: 'text',
    isNull: 1,
    isSearch: 0,
  }
]

// 备件审核结算回执字段
export const TaskBalanceReceiptExportFields: Field[] = [
  {
    isSystem: 1,
    fieldName: 'spare_name',
    field: 'spare_name',
    displayName: t('common.fields.sparePart.displayName'),
    label: t('common.fields.sparePart.displayName'),
    formType: 'text',
    isNull: 1,
    isSearch: 0,
  },
  {
    isSystem: 1,
    fieldName: 'service_name',
    field: 'service_name',
    displayName: t('common.fields.serviceName.displayName'),
    label: t('common.fields.serviceName.displayName'),
    formType: 'text',
    isNull: 1,
    isSearch: 0,
  },
]

export const TaskLinkmanFields: Field[] = [
  {
    tableName: 'customer',
    isSystem: 1,
    fieldName: 'tlmName',
    displayName: t('common.fields.contact.displayName'),
    exportAlias: 'customerLinkman',
    formType: 'select',
    defaultValue: null,
    isNull: 1,
    isSearch: 1,
    placeHolder: null,
    setting: {},
    orderId: 1,
    isDelete: 0
  },
  {
    tableName: 'customer',
    isSystem: 1,
    fieldName: 'tlmPhone',
    exportAlias: 'customerPhone',
    displayName: t('common.fields.phone.displayName'),
    formType: 'text',
    defaultValue: null,
    isNull: 1,
    isSearch: 1,
    placeHolder: null,
    setting: {},
    orderId: 1,
    isDelete: 0
  }
]

export const TaskAddressFields: Field[] = [
  {
    tableName: 'customer',
    isSystem: 1,
    fieldName: 'taddress',
    exportAlias: 'customerAddress',
    displayName: t('common.fields.customerAddress.displayName'),
    formType: 'address',
    defaultValue: null,
    isNull: 1,
    isSearch: 1,
    placeHolder: null,
    setting: {},
    orderId: 1,
    isDelete: 0
  }
]

export const TaskProductFields: Field[] = [
  {
    tableName: 'task',
    isSystem: 1,
    fieldName: 'product',
    exportAlias: 'product',
    displayName: t('common.fields.product.displayName'),
    formType: 'text',
    defaultValue: null,
    isNull: 1,
    isSearch: 1,
    placeHolder: null,
    setting: {},
    orderId: 1,
    isDelete: 0
  }
]

export const TaskAdvancedAddressFields: Field[] = [
  {
    tableName: 'customer',
    isSystem: 1,
    fieldName: 'area',
    exportAlias: 'customerAddress',
    displayName: t('common.fields.area.displayName'),
    formType: 'address',
    defaultValue: null,
    isNull: 1,
    isSearch: 1,
    placeHolder: null,
    setting: {},
    orderId: 1,
    isDelete: 0
  },
  {
    tableName: 'customer',
    isSystem: 1,
    fieldName: 'cusAddress',
    displayName: t('common.fields.detailAddress.displayName'),
    formType: 'text',
    defaultValue: null,
    isNull: 1,
    isSearch: 1,
    placeHolder: null,
    setting: {},
    orderId: 1,
    isDelete: 0
  }
]

export const TaskTypeField: Field = {
  tableName: 'customer',
  isSystem: 1,
  fieldName: 'templateName',
  exportAlias: 'templateName',
  displayName: t('common.fields.taskType.displayName'),
  formType: 'text',
  defaultValue: null,
  isNull: 0,
  isSearch: 1,
  placeHolder: null,
  setting: {
    customerNameDuplicate: false,
  },
  orderId: 0,
  isDelete: 0
}

export const TaskExportBalanceFields: Field[] = [
  // 备件费
  {
    displayName: TaskFieldDisplayNameMappingEnum.SparePartsPrice,
    fieldName: TaskFieldNameMappingEnum.SparePartsPrice
  },
  // 服务费
  {
    displayName: TaskFieldDisplayNameMappingEnum.ServicePartsPrice,
    fieldName: TaskFieldNameMappingEnum.ServicePartsPrice
  },
  // 折扣费用
  {
    displayName: TaskFieldDisplayNameMappingEnum.Discount,
    fieldName: TaskFieldNameMappingEnum.Discount
  },
  // 合计费用
  {
    displayName: TaskFieldDisplayNameMappingEnum.TotalPrice,
    fieldName: TaskFieldNameMappingEnum.TotalPrice
  },
  // 成本
  {
    displayName: TaskFieldDisplayNameMappingEnum.TotalCost,
    fieldName: TaskFieldNameMappingEnum.TotalCost
  },
  // 毛利
  {
    displayName: TaskFieldDisplayNameMappingEnum.TotalProfit,
    fieldName: TaskFieldNameMappingEnum.TotalProfit
  },
  // 结算状态
  {
    displayName: TaskFieldDisplayNameMappingEnum.BalanceConfirm,
    fieldName: TaskFieldNameMappingEnum.BalanceConfirm
  },
  // 结算时间
  {
    displayName: TaskFieldDisplayNameMappingEnum.BalanceTime,
    fieldName: TaskFieldNameMappingEnum.BalanceTime
  },
  // 结算人
  {
    displayName: TaskFieldDisplayNameMappingEnum.BalanceUserName,
    fieldName: TaskFieldNameMappingEnum.BalanceUserName
  }
]

export const TaskExportGroupTextEnum = {
  Balance: t('common.task.TaskExportGroupTextEnum.balance'),
  Card: t('common.task.TaskExportGroupTextEnum.card'),
  System: t('common.task.TaskExportGroupTextEnum.system'),
  Task: t('common.task.TaskExportGroupTextEnum.task'),
  TaskReceipt: t('common.task.TaskExportGroupTextEnum.taskReceipt'),
}

export const TaskExportGroupValueEnum = {
  Balance: t('common.task.TaskExportGroupValueEnum.balance'),
  Card: t('common.task.TaskExportGroupValueEnum.bard'),
  System: t('common.task.TaskExportGroupValueEnum.system'),
  Task: t('common.task.TaskExportGroupValueEnum.task'),
  TaskReceipt: t('common.task.TaskExportGroupValueEnum.taskReceipt'),
}

export const UserNameConvertMap: Record<string, string> = {
  [TaskFieldNameMappingEnum.CreateUserName]: 'createUser',
  [TaskFieldNameMappingEnum.ExecutorName]: 'executorUser',
  [TaskFieldNameMappingEnum.Customer]: 'customerName',
  [TaskFieldNameMappingEnum.AllotName]: 'allotUser'
}

export default {
  TaskReceiptExportFields
}